package com.pinapel.aixml.controller;


import com.pinapel.aixml.models.Model;
import com.pinapel.aixml.ui.ArbolesUI;


/**
 * Controlador para la vista arboles
 * @author Ruben Perez Lujano
 * @since Mayo 2012
 */
public class ArbolesController implements IArbolesController {
	
	private IMainController mMainController;
	private ITreeController mXmlTreeController;
    private ITreeController mXsdTreeController;
    private ArbolesUI mView;
	
    
    /**
     * Constructor controlador para vista arboles -ArbolesUI-
     * @param topController Controlador Principal
     */
    public ArbolesController(IMainController topController){
    	this.mMainController=topController;
    	this.mXmlTreeController=new TreeController(this);
    	this.mXsdTreeController=new TreeController(this);
    }
    
    @Override
	public IMainController getMainController() {
		return mMainController;
	}

	@Override
	public Model getModel() {
		return mMainController.getModel();
	}

	@Override
	public void setView(ArbolesUI mView) {
		this.mView = mView;
		this.mView.setController(this);
		this.assingViewsToControllers();
	}
	//Asisgnamos las vistas a los controladores del Arbol XML y XSD
	private void assingViewsToControllers(){
		mXmlTreeController.setView(mView.getXmlTree());
		mXsdTreeController.setView(mView.getXsdTree());		
	}


	@Override
	public ITreeController getXMLTreeController() {
		return mXmlTreeController;
	}

	@Override
	public ITreeController getXSDTreeController() {
		return mXsdTreeController;
	}
}
